package com.huiyeji.mail.trigger;

import com.huiyeji.mail.trigger.processor.EmailProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass(EmailMonitor.class)
@EnableConfigurationProperties(HspMailTriggerProperties.class)
public class HspMailTriggerAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnBean(EmailProcessor.class)
    public EmailMonitor emailMonitor(HspMailTriggerProperties hspMailTriggerProperties, EmailProcessor emailProcessor) {
        return new EmailMonitor(hspMailTriggerProperties,emailProcessor);
    };
}
